﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TongHopBookFlightDAO.DAO
{
    public class ChiTietChuyenBayDAO
    {

        public static int Insert(ChiTietChuyenBay _obj)
        {
            int ID = -1;
            try
            {
                BookFlightDataContext context = new BookFlightDataContext();
                context.ChiTietChuyenBays.InsertOnSubmit(_obj);
                context.SubmitChanges();
                ID = _obj.ChiTietChuyenBayID;
            }
            catch { }
            return ID;
        }

        /// <summary>
        ///  Lấy tất cả chi tiết chuyến bay dựa vào chuyên bay ID
        /// </summary>
        /// <param name="flightID">Chuyến bay ID</param>
        public static List<ChiTietChuyenBay> SelectByFlightID(int chuyenBayID)
        {
            List<ChiTietChuyenBay> listObjResults = new List<ChiTietChuyenBay>();
            try
            {
                BookFlightDataContext context = new BookFlightDataContext();
                listObjResults = context.ChiTietChuyenBays.Where(p => p.ChuyenBayID == chuyenBayID).ToList();

            }
            catch { }
            return listObjResults;
        }
    }
}
